package me.siphone.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.Nullable;
import me.siphone.fragment.DeviceListFragment;
import me.siphone.fragment.StationListFragment;
import org.linphone.R;

public class ContainerActivity extends BaseActivity {

    TextView tvTitle;
    ImageView ivBack;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_container);

        tvTitle = findViewById(R.id.tv_title);
        ivBack = findViewById(R.id.iv_back);

        ivBack.setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        finish();
                    }
                });

        int type = getIntent().getIntExtra("type", -1);
        switch (type) {
            case 0:
                tvTitle.setText("监测数据");
                getSupportFragmentManager()
                        .beginTransaction()
                        .add(R.id.fl_content, new StationListFragment())
                        .commitNowAllowingStateLoss();
                break;
            case 1:
                tvTitle.setText("设备列表");
                getSupportFragmentManager()
                        .beginTransaction()
                        .add(R.id.fl_content, new DeviceListFragment())
                        .commitNowAllowingStateLoss();
                break;
        }
    }
}
